package com.linkage.category.service;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkage.category.pojo.Category;
import com.linkage.category.repository.CategoryRepository;
import com.linkage.user.pojo.User;

/**
 * 
 * @author LuoYunHui
 *
 */
@Service
public class CategoryService {

	@Autowired
	private CategoryRepository categoryRepository;
	
	public List<Category> queryAll() {
        return this.categoryRepository.queryAll();
    }

    public void save(Category category) {
        //user.setPkId(UUID.randomUUID().toString());
        this.categoryRepository.addCategory(category);
    }

    public void update(Category category) {
        this.categoryRepository.UpdateCategory(category);
    }

    public void delete(int categoryId) {
        this.categoryRepository.deleteCategoryById(categoryId);
    }

    public Category loadOne(int categoryId) {
        return this.categoryRepository.loadOne(categoryId);
    }
    
    public Category loadByCategoryName(@Param("categoryName") String categoryName){
        return this.categoryRepository.loadByCategoryName(categoryName);
    }
	
	
}
